#include<iostream>
using namespace std;

template<class T>
class seqlist
{
public:
  seqlist():_data(new T[4]),_size(0),_capacity(4) {}
  seqlist(size_t n) :_data(new T[n]), _size(0), _capacity(n) {}
  ~seqlist()
  {
    delete[] _data;
    _data = nullptr;
    _size = _capacity = 0;
  }

  void PushBack(T x)
  {
    CheckCapaciy();
    _data[_size] = x;
    _size++;
  }
  
  size_t size() const {return  _size;}
  size_t capacity() const {return _capacity;}
  
  void print()
  {
    for(int i = 0; i < _size; i++)
    {
      cout<< _data[i] << " ";
    }
    cout<<endl;
  }


private:
  T* _data;
  size_t _size;
  size_t _capacity;

  void CheckCapaciy()
  {
    if(_size == _capacity)
    {
      size_t newcapcacity = _capacity == 0 ? 4 : _capacity * 2;
      
      T* temp = new T[newcapcacity];
    
      for(size_t i = 0; i < _size; i++)
      {
        temp[i] = _data[i];
      }
    
      delete[]  _data;

      _data = temp;

      _capacity = newcapcacity;
    }

  }
};


int main()
{

  seqlist<int> s1;
  s1.PushBack(11);
  s1.PushBack(11);
  s1.PushBack(11);
  s1.PushBack(11);
  s1.PushBack(11);
  s1.PushBack(11);
  s1.PushBack(11);
  s1.PushBack(11);
  s1.PushBack(11);
  s1.PushBack(11);
  s1.PushBack(11);

  s1.PushBack();











  return 0;
}
